/*
    SlideScript - minimalistic top-down scripting language.
    (C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)

    View README file supplied with this software for more details
*/

#include "inc/deps.h"
#include "inc/enc.h"

char *ss_encrypt(char *string)
{
    int i;
    int str_len;

    str_len = strlen(string);

    for(i = 0; (i < str_len && string[i] != NULLBYTE); i++)
        string[i] = string[i] + ENCOFFSET;

    for(i = 0; (i < str_len && string[i] != NULLBYTE); i+=3)
        string[i] = string[i] - ENCSTEPODD;

    for(i = 0; (i < str_len && string[i] != NULLBYTE); i+=4)
        string[i] = string[i] + ENCSTEPEVEN;

    return string;
}

char *ss_decrypt(char *string)
{
    int i;
    int str_len;

    str_len = strlen(string);

    for(i = 0; (i < str_len && string[i] != NULLBYTE); i++)
        string[i] = string[i] - ENCOFFSET;

    for(i = 0; (i < str_len && string[i] != NULLBYTE); i+=3)
        string[i] = string[i] + ENCSTEPODD;

    for(i = 0; (i < str_len && string[i] != NULLBYTE); i+=4)
        string[i] = string[i] - ENCSTEPEVEN;

    return string;
}

